#pragma once

#include "e2d/core/pch.h"
#include "e2d/core/physics/PxUtils.h"

namespace e2d
{

    struct  PhysicsTriggerCallback :public physx::PxSimulationEventCallback
    {
        static PxFilterFlags DefaultFilterShader(PxFilterObjectAttributes attributes0, PxFilterData filterData0,
            PxFilterObjectAttributes attributes1, PxFilterData filterData1,
            PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize)
        {
            PX_UNUSED(attributes0); PX_UNUSED(attributes1);
            PX_UNUSED(filterData0); PX_UNUSED(filterData1);
            PX_UNUSED(constantBlock); PX_UNUSED(constantBlockSize);

            pairFlags = PxPairFlag::eCONTACT_DEFAULT
                | PxPairFlag::eNOTIFY_TOUCH_FOUND
                | PxPairFlag::eNOTIFY_TOUCH_LOST
                | PxPairFlag::eNOTIFY_CONTACT_POINTS;
            return PxFilterFlags();
        }

        void onContact(const PxContactPairHeader& pairHeader, const PxContactPair* pairs, PxU32 nbPairs) override {
            // ������ײ
            ztclog::info("on contacted");

            for (int i = 0; i < nbPairs; i++)
            {
                auto pair = pairs[i];
                pairHeader.actors[0];
                pairHeader.actors[1];
            }

        }

        void onTrigger(PxTriggerPair* pairs, PxU32 count) override {
            // �����������¼�
            ztclog::info("on trigger");

            for (PxU32 i = 0; i < count; i++)
            {
                if (pairs[i].status & PxPairFlag::eNOTIFY_TOUCH_FOUND)
                {
                    std::cout << " on trigger" << std::endl;
                }
            }
        }

        void onSleep(PxActor** actors, PxU32 count) override {
            // ĳЩ���徲ֹ��
            ztclog::info("on sleep");

        }

        void onWake(PxActor** actors, PxU32 count) override {
            // ĳЩ���忪ʼ����
            ztclog::info("on wake");

        }

        void onAdvance(const PxRigidBody* const* bodyBuffer, const PxTransform* poseBuffer, const PxU32 count) override {
            // Substepping ʱʹ��
            ztclog::info("on advanced");

        }

        void onConstraintBreak(PxConstraintInfo* constraints, PxU32 count) override
        {
            ztclog::info("on constraintBreak");

        }


    };

};